package com.lemner.ke.fragment;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.lemner.ke.R;
import com.lemner.ke.adapter.VideoRvAdapter;
import com.lemner.ke.base.BaseFragment;
import com.lemner.ke.base.BaseListBean;
import com.lemner.ke.base.BaseListener;
import com.lemner.ke.bean.RecommedBean;
import com.lemner.ke.bean.VideoRvBean;
import com.lemner.ke.model.knowledge.VideoRvModel;

import java.util.ArrayList;
import java.util.List;

public class VideoFragment extends BaseFragment{

    RecyclerView rec;
    VideoRvAdapter rvAdapter;
    public static VideoFragment getInstance(){
        return new VideoFragment();
    }
    @Override
    public int getLayoutFile() {
        return R.layout.fragment_video;
    }

    @Override
    public void initSetting() {

    }

    @Override
    public void initView() {
        rec=findViewById(R.id.rv_fragment_video);
        rvAdapter = new VideoRvAdapter(R.layout.item_video);

        //创建布局管理
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        rec.setLayoutManager(linearLayoutManager);
        rec.setAdapter(rvAdapter);

    }

    @Override
    public void initEvent() {

    }

    @Override
    public void initData() {
            new VideoRvModel().getVideoList(new BaseListener() {
                @Override
                public void onResponse(Object o) {
                    if (o != null) {
                        BaseListBean<VideoRvBean> bean = (BaseListBean<VideoRvBean>) o;
                        if (bean != null) {
                            List<VideoRvBean> beanList = bean.getData();
                            rvAdapter.addData(beanList);
                        }
                    }
                }

                @Override
                public void onFail(String msg) {

                }
            });
    }

    @Override
    public void onClick(View v) {

    }
}
